<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateNoticeTable extends Migration
{
    const NOTICE = 'notices';
    const NOTICE_USER = 'notice_users';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 通知内容表
        Schema::create(self::NOTICE, function (Blueprint $table) {
            $table->increments('id');
            $table->string('title', 50);
            $table->string('content', 1000);
            $table->timestamps();
        });

        Schema::create(self::NOTICE_USER, function(Blueprint $table) {
            $table->increments('id');
            $table->integer('notice_id');
            $table->integer('user_id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(self::NOTICE);
        Schema::dropIfExists(self::NOTICE_USER);
    }
}
